home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 62 / 062.d81 / stats toolbox (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  26KB  |  760 lines

  1. 100 rem stats toolbox
  2. 102 goto116
  3. 104 :
  4. 106 getq$:ifq$=""then106
  5. 108 return
  6. 110 :
  7. 112 printtab((40-len(a$))/2);t$;a$:return
  8. 114 :
  9. 116 sa=679:forj=satosa+35:readb:poke j,b:next
  10. 118 data 32,253,174,32,158,183,138,56,201,40,144,5,162,14,76,139,227,72
  11. 120 data 32,253,174,32,158,183,138,56,201,25,176,238,104,168,24,76,240,255
  12. 122 :
  13. 123 qz=0:qw=1
  14. 124 poke 53280,.:poke 53281,.:poke 646,1:poke 53272,23:fl=0:dim cx(101)
  15. 126 def fn d4(x)=int(10000*x+.05)/10000
  16. 128 def fn d1(x)=int(10*x+.05)/10:def fn frc(x)= x-int(x)
  17. 129 def fn cn(x)=20-len(mu$(x))/2
  18. 130 so$="                                       ":sr$=""+so$
  19. 132 dim mu$(6):mu$(2)=" [193]verage and [211]td.[196]ev ":mu$(3)=" [212]-test "
  20. 134 mu$(1)=" [195]hi [211]quare ":mu$(4)=" [210]andom [206]umbers "
  21. 135 mu$(6)=" [209]uit ":mu$(5)=" [205]edian "
  22. 136 :
  23. 138 rn$=chr$(18):rf$=chr$(146)
  24. 140 print"[147]              [162][162][162][162][162][162][162][162][162][162][162][162][155]            ";
  25. 142 print"                [161][155]          [161][155][146]      ";
  26. 144 print"               [172][162][162][162][162][162][162][162][162][162][162][162][172][162][187][162][162][162][162][162][162][162][162]";
  27. 146 print"[162][162][162][146][161][155]             [161][155]           [161][155] [161]";
  28. 148 print"[155][146]           [161][155]             [188][146][162][162][162][162][162][162][162]";
  29. 150 print"[162][162][162][162][188][146][162][190][146][162][162][162][162][162][162][162][162][162][162][162][161][155]             [161][155]";
  30. 152 print"           [161] [161][155][146]           [161][155]        ";
  31. 154 print"     [161][155]           [188][146][162][190][155][146]           ";
  32. 156 print"[161][155]             [161][155]                      ";
  33. 158 print"   [161][155]             [161][155]                  ";
  34. 160 print"       [161][155]             [188][146][162][162][162][162][162][162][162][162][162][162][162][162][162]";
  35. 162 print"[162][162][162][162][162][162][162][162][162][162][162][162][161][155]                          "
  36. 164 print"[145][211]tatistician's [212]oolbox"
  37. 166 print"              [208]ress any key  "
  38. 168 gosub1574:poke646,1:gosub106:goto186
  39. 170 :
  40. 172 print"";
  41. 174 forx=1to12:printso$:next:return
  42. 176 :
  43. 178 print"[147]":gosub180:fl=0:t$=rn$:return
  44. 180 syssa,0,12
  45. 182 forx=1to12:printsr$:next:syssa,0,13:return
  46. 184 :
  47. 186 print"[147]     [207]ften called 'number crunching',   ";
  48. 188 print"statistics offers us a lot of tools to  ";
  49. 190 print"give MEANING to what is otherwise a     ";
  50. 192 print"jumble of numbers.  We say Joe Baseball ";
  51. 194 print"is batting 500 this season.  We then    ";
  52. 196 print"know he is hitting one for every one he ";
  53. 198 print"misses.  We can also see that he has the";
  54. 200 print"edge on Matty Homeplate who is batting  ";
  55. 202 print"470.  The batting average is a crunched ";
  56. 204 print"number, based on a long list of single  ";
  57. 206 print"swings.  [215]e can [213][211][197] the batting average ";
  58. 208 print"where the list of single swing results  ";
  59. 210 print"would simply confuse us.                ";
  60. 212 print"                                        ";
  61. 214 print"     This toolbox is an introduction to ";
  62. 216 print"some other statistical tools that give  ";
  63. 218 print"a single number to describe a lot of    ";
  64. 220 print"numbers.  You'll be able to view a      ";
  65. 222 print"tutorial as well as try using the tools ";
  66. 224 print"for yourself.                           ";
  67. 226 print"             [208]ress any key  "
  68. 228 gosub106
  69. 230 t$=rf$:print"[147]              [212]he [212]oolbox"
  70. 232 print"              ==========="
  71. 234 for x=1 to 6:print tab(fn cn(x))mu$(x):print:next
  72. 236 print"[195][210][211][210] [213][208]/[196][206] to select / [210][197][212][213][210][206] to choose"
  73. 237 print" [198]1 - background color  [198]7 - text color":x=1:goto240
  74. 238 print"":goto242
  75. 240 print""
  76. 242 printtab(fn cn(x))"";mu$(x)
  77. 244 getqf$:ifqf$=""then244
  78. 245 ifqf$="[133]"orqf$="[136]"then251
  79. 246 ifqf$=chr$(13)then264
  80. 248 ifqf$=""thenx=x+1:goto255
  81. 249 ifqf$="[145]"thenx=x-1:goto254
  82. 250 goto244
  83. 251 ifqf$="[133]"thenqz=qz+1:qz=qzand15:ifqz=qwthenqz=qz+1:qz=qzand15
  84. 252 ifqf$="[136]"thenqw=qw+1:qw=qwand15:ifqw=qzthenqw=qw+1:qw=qwand15
  85. 253 poke53281,qz:poke53280,qz:poke646,qw:goto230
  86. 254 print"[145]"tab(fn cn(x+1))mu$(x+1)"[145][145][145][145]":goto256
  87. 255 print"[145]"tab(fn cn(x-1))mu$(x-1)
  88. 256 ifx>6thenx=1:goto240
  89. 257 ifx<1thenx=6:goto238
  90. 258 print""tab(fn cn(x))"";mu$(x)
  91. 260 goto244
  92. 262 :
  93. 264 onxgoto266,828,960,1164,1296,1564
  94. 266 t$=rf$:goto284
  95. 268 sys sa,0,3
  96. 270 print"        [176][192][192][192][192][192][192][178][192][192][192][192][192][192][174]"
  97. 272 print"        [221]      [221]      [221]"
  98. 274 print"        [171][192][192][192][192][192][192][219][192][192][192][192][192][192][219][192][192][192][192][192][192]"
  99. 276 print"        [221]      [221]      [221]"
  100. 278 print"        [173][192][192][192][192][192][192][219][192][192][192][192][192][192][219][192][192][192][192][192][192]"
  101. 280 print"               [221]      [221]"
  102. 282 return
  103. 284 print"[147] [212]he [195]hi-square [212]est [146]"
  104. 286 a$="[212]he basic idea behind the [195]hi":gosub112
  105. 288 a$="[211]quare is to find out if a set of":gosub112
  106. 290 a$="numbers just happened that way by":gosub112
  107. 292 a$="'chance'  - or if there was some":gosub112
  108. 294 a$="social or economic factor which":gosub112
  109. 296 a$="might have influenced the outcome":gosub112
  110. 298 a$="to some extent.":gosub112
  111. 300 a$="  [212]-[212]utorial   [196]-[196]ata [197]ntry   [205]-[205]enu  [146]":fl=1:da=0:gosub1536
  112. 302 on ch goto304,230,610
  113. 304 print"[147]":gosub180:fl=0:t$=rn$
  114. 306 a$="[200]ere we see the typical 2 by 2":gosub112
  115. 308 a$="[195]hi-square grid.  [212]his one displays":gosub112
  116. 310 a$="the results of a (fictitious) survey":gosub112
  117. 312 a$="where people were asked whether they":gosub112
  118. 314 a$="preferred using a [195]ommodore 64 or an":gosub112
  119. 316 a$="[201][194][205]-[208][195].  [193]lso, their residence was":gosub112
  120. 318 a$="categorized as [197]ast or [215]est of the":gosub112
  121. 320 a$="[205]ississippi [210]iver.":gosub112
  122. 322 gosub268
  123. 324 sys sa,4,4:print"[197]ast":sys sa,4,6:print"[215]est"
  124. 326 sys sa,11,4:print"344":sys sa,17,4:print"451":sys sa,11,6:print"482"
  125. 328 sys sa,17,6:print"499":sys sa,10,2:print"[195]-64":sys sa,17,2:print"[201][194][205]"
  126. 330 gosub1536:on ch goto332,230
  127. 332 gosub180
  128. 334 a$="[212]he survey results are set up in":gosub112
  129. 336 a$="a grid of 2 rows and 2 columns seen":gosub112
  130. 338 a$="here. [201]t looks like a small":gosub112
  131. 340 a$="spreadsheet. [201]f we had included [193]pple":gosub112
  132. 342 a$="computers in our survey we would":gosub112
  133. 344 a$="have a grid of 2 rows by 3 columns.":gosub112
  134. 346 a$="[215]e put in the row and":gosub112
  135. 348 a$="column totals because they are":gosub112
  136. 350 a$="needed to do the [195]hi-square.":gosub112
  137. 352 sys sa,23,4:print"795":sys sa,23,6:print"981":sys sa,11,8:print"826"
  138. 354 sys sa,17,8:print"950":sys sa,23,8:print "1776":gosub1536
  139. 356 on ch goto358,230
  140. 358 gosub180
  141. 360 a$="[212]he [195]hi-square test looks at the":gosub112
  142. 362 a$="[193][195][212][213][193][204] survey results we see here":gosub112
  143. 364 a$="and compares them to what would":gosub112
  144. 366 a$="be [197][216][208][197][195][212][197][196] by 'chance.'":gosub112
  145. 368 a$="[215]e want to know if people in one area":gosub112
  146. 370 a$="really prefer one computer over":gosub112
  147. 372 a$="another or these results just":gosub112
  148. 374 a$="happened by chance.":gosub112:gosub1536:onchgoto376,230
  149. 376 gosub180
  150. 378 a$="[215]e start by finding the corresponding":gosub112
  151. 380 a$="'expected' value for [197][193][195][200] of the 4":gosub112
  152. 382 a$="actual values shown.  [212]he expected":gosub112
  153. 384 a$="value is found by [205][213][204][212][201][208][204][217][201][206][199] the":gosub112
  154. 386 a$="corresponding row and column totals":gosub112
  155. 388 a$="for each value then [196][201][214][201][196][201][206][199] the":gosub112
  156. 390 a$="product by the grand total.":gosub112
  157. 392 a$="826 times 795 divided by 1776 is":gosub112
  158. 394 a$="369.8 - the expected value for 344.":gosub112
  159. 396 sys sa,10,4:print" 344 [146]"
  160. 398 sys sa,12,10:print"^":sys sa,29,4:print"_":sys